/* $Id$ */
package org.crazydays.gameplan.map.swing;


import org.junit.*;
import static org.junit.Assert.*;

import static org.easymock.EasyMock.*;
import static org.easymock.classextension.EasyMock.*;

import org.crazydays.gameplan.Controller;
import org.crazydays.gameplan.map.IGameMap;

/**
 * JMapFrameUnitTest
 */
public class JMapFrameUnitTest
{
    /**
     * Test setGridVisible(boolean).
     */
    @Test
    public void testSetGridVisible()
    {
        // mocks
        Controller controller = createMock(Controller.class);
        IGameMap gameMap = createMock(IGameMap.class);
        JMapGrid grid = createMock(JMapGrid.class);

        // expect
        expect(gameMap.getName()).andReturn("name");
        grid.setVisible(true);

        // replay
        replay(controller, gameMap, grid);

        // setup
        JMapFrame frame = new JMapFrame(controller, gameMap);
        frame.grid = grid;

        // test
        frame.setGridVisible(true);

        // verify
        verify(controller, gameMap, grid);
    }

    /**
     * Test isGridVisible().
     */
    @Test
    public void testIsGridVisible()
    {
        // mocks
        Controller controller = createMock(Controller.class);
        IGameMap gameMap = createMock(IGameMap.class);
        JMapGrid grid = createMock(JMapGrid.class);

        // expect
        expect(gameMap.getName()).andReturn("name");
        expect(grid.isVisible()).andReturn(true);

        // replay
        replay(controller, gameMap, grid);

        // setup
        JMapFrame frame = new JMapFrame(controller, gameMap);
        frame.grid = grid;

        // test
        boolean result = frame.isGridVisible();

        // verify
        verify(controller, gameMap, grid);
        assertEquals("result", true, result);
    }
}
